package com.huangyi;

import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt(); // 数组长度
        int m = scan.nextInt(); // 查询次数

        int[] arr = new int[n + 1];   // 原始数组 (1-based)
        long[] dp = new long[n + 1];  // 前缀和数组

        // 输入数组
        for (int i = 1; i <= n; i++) {
            arr[i] = scan.nextInt();
        }

        // 构建前缀和
        for (int i = 1; i <= n; i++) {
            dp[i] = dp[i - 1] + arr[i];
        }

        // 处理查询
        while (m-- > 0) {
            int l = scan.nextInt();
            int r = scan.nextInt();
            System.out.println(dp[r] - dp[l - 1]);
        }
    }
}